package com.filldream.fastboot.web.controller.common;

import com.filldream.fastboot.common.entity.B;
import com.filldream.fastboot.core.manager.CfAnnManager;
import com.filldream.fastboot.core.manager.CfArticleManager;
import com.filldream.fastboot.core.manager.CfNewsManager;
import com.filldream.fastboot.core.manager.CfReportManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;

@AllArgsConstructor
@Api(tags = "东财接口")
@RestController
@RequestMapping("/common/eastCf")
public class EastCfController {

    private final CfArticleManager cfArticleManager;

    private final CfReportManager cfReportManager;

    private final CfAnnManager cfAnnManager;

    private final CfNewsManager cfNewsManager;

    @GetMapping(value = "/article/refresh")
    @ApiOperation(value = "同步资讯",notes = "刷新同步资讯")
    public B news(String stockCode) {
        return cfArticleManager.refreshArticle(stockCode);
    }

    @GetMapping(value = "/article/autoSendOwner")
    @ApiOperation(value = "发送资讯机器人",notes = "发送资讯机器人")
    public B autoSendOwner() {
        return cfArticleManager.autoSendOwner(Arrays.asList("zr","sun"));
    }

    @GetMapping(value = "/report/refresh")
    @ApiOperation(value = "同步研报",notes = "刷新同步研报")
    public B reportRefresh(String stockCode) {
        return cfReportManager.refreshReport(stockCode);
    }

    @GetMapping(value = "/report/autoSendOwner")
    @ApiOperation(value = "发送研报机器人",notes = "发送研报机器人")
    public B reportAutoSendOwner() {
        return cfReportManager.autoSendOwner(Arrays.asList("zr","sun"));
    }

    @GetMapping(value = "/ann/refresh")
    @ApiOperation(value = "同步公告",notes = "刷新同步公告")
    public B annRefresh(String stockCode) {
        return cfAnnManager.refreshAnn(stockCode);
    }

    @GetMapping(value = "/ann/autoSendOwner")
    @ApiOperation(value = "发送公告机器人",notes = "发送公告机器人")
    public B annAutoSendOwner() {
        return cfAnnManager.autoSendOwner(Arrays.asList("zr","sun"));
    }


    @GetMapping(value = "/news/refresh")
    @ApiOperation(value = "同步东财新闻",notes = "刷新同步东财新闻")
    public B newsRefresh() {
        return cfNewsManager.refreshNews();
    }

    @GetMapping(value = "/news/autoSendOwner")
    @ApiOperation(value = "发送东财新闻机器人",notes = "发送东财新闻机器人")
    public B newsAutoSendOwner() {
        return cfNewsManager.autoSendOwner(Arrays.asList("zr","sun"),true);
    }

}
